package thinkingJava.chapter19;
import java.util.*;

import static thinkingJava.chapter19.AlarmPoints.*;
import static util.Print.*;

interface Command {
	void action();
}
public class EnumMaps {
	public static void main(String[] args) {
		EnumMap<AlarmPoints, Command> em = new EnumMap<AlarmPoints, Command>(AlarmPoints.class);
		em.put(KITCHEN,  new Command(){
			public void action() {
				print("kitchen fires!");
			}
		});
		em.put(BATHROOM, new Command() {
			public void action(){
				print("bathroom alert!");
			}
		});
		for (Map.Entry<AlarmPoints, Command> e : em.entrySet()) {
			printnb(e.getKey() + " : ");
			e.getValue().action();
		}
		try {
			em.get(UTILITY).action();
		}catch (Exception e) {
			print(e);
		}
	}
}
